package com.imonsoft.sqm.dao.basedata;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.basedata.IpicTarget;
import com.imonsoft.sqm.pojo.basedata.IpicTargetExample;

@SuppressWarnings("deprecation")
@Repository("ipicTargetDAO")
public class IpicTargetDAOImpl extends SqlMapClientDaoSupport implements IpicTargetDAO {

    /**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public IpicTargetDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int countIpicTargetByExample(IpicTargetExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("tt_ipic_target.ibatorgenerated_countByExample",
				example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int deleteIpicTargetByExample(IpicTargetExample example) {
		int rows = getSqlMapClientTemplate().delete("tt_ipic_target.ibatorgenerated_deleteByExample",
				example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int deleteIpicTargetByPrimaryKey(Long id) {
		IpicTarget key = new IpicTarget();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete("tt_ipic_target.ibatorgenerated_deleteByPrimaryKey",
				key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public Long insertIpicTarget(IpicTarget record) {
		Object newKey = getSqlMapClientTemplate().insert("tt_ipic_target.ibatorgenerated_insert",
				record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public Long insertIpicTargetSelective(IpicTarget record) {
		Object newKey = getSqlMapClientTemplate().insert("tt_ipic_target.ibatorgenerated_insertSelective",
				record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<IpicTarget> selectIpicTargetByExample(IpicTargetExample example) {
		List<IpicTarget> list = getSqlMapClientTemplate().queryForList("tt_ipic_target.ibatorgenerated_selectByExample",
				example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public IpicTarget selectIpicTargetByPrimaryKey(Long id) {
		IpicTarget key = new IpicTarget();
		key.setId(id);
		IpicTarget record = (IpicTarget) getSqlMapClientTemplate().queryForObject("tt_ipic_target.ibatorgenerated_selectByPrimaryKey",
				key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int updateIpicTargetByExampleSelective(IpicTarget record,
			IpicTargetExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("tt_ipic_target.ibatorgenerated_updateByExampleSelective",
				parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int updateIpicTargetByExample(IpicTarget record,
			IpicTargetExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("tt_ipic_target.ibatorgenerated_updateByExample",
				parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int updateIpicTargetByPrimaryKeySelective(IpicTarget record) {
		int rows = getSqlMapClientTemplate().update("tt_ipic_target.ibatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	public int updateIpicTargetByPrimaryKey(IpicTarget record) {
		int rows = getSqlMapClientTemplate().update("tt_ipic_target.ibatorgenerated_updateByPrimaryKey",
				record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table tt_ipic_target
	 * @ibatorgenerated  Thu May 30 11:35:38 CST 2013
	 */
	private static class UpdateByExampleParms extends IpicTargetExample {
		private Object record;

		public UpdateByExampleParms(Object record, IpicTargetExample example) {
			super(example);
			this.record = record;
		}

		@SuppressWarnings("unused")
		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<IpicTarget> getDataGrid(IpicTargetExample example, Pager pager) {

		if (example == null) {
			example = new IpicTargetExample();
		}
		int total = countIpicTargetByExample(example);
		List<IpicTarget> rows = getSqlMapClientTemplate().queryForList("tt_ipic_target.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
		DataGrid<IpicTarget> dataGrid = new DataGrid<IpicTarget>(total, rows);
		return dataGrid;

	}
 
}